package com.wx.gof.pattern.behavioral.strategy;

import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName ApprovalFactory
 * @Author wx
 * @Description 生产策略工厂
 * @Date 2018-12-13-21:19
 */
public class ApprovalFactory {
    private static Map<String, IApproval> ApprovalMap = new HashMap<>();
    static {
        ApprovalMap.put(ApprovalKey.COUPONS,new CouponsApproval());
        ApprovalMap.put(ApprovalKey.MATERIAL,new MaterialApproval());
        ApprovalMap.put(ApprovalKey.TEACHER,new TeacherApproval());
    }
    private static  IApproval DEFAULTAPPROVAL =  new DefaultApproval();
    public static IApproval getApproval(String ApprovalKey){
        IApproval iApproval = ApprovalMap.get(ApprovalKey);
        return iApproval == null ? DEFAULTAPPROVAL : iApproval;
    }

    interface ApprovalKey{
        final static String COUPONS = "Coupons";
        final static String MATERIAL= "Material";
        final static String TEACHER = "Teacher";
    }
}
